package com;

import com.dao.UserDao;
import com.pojo.User;
import com.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@ComponentScan // 扫描项目中的bean类
@Configuration // 说明本项目是IOC配置类
@EnableAspectJAutoProxy
public class AppConfig {
    public static void main(String[] args){
        ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
 //        User user = ctx.getBean(User.class);
 //       System.out.println(user);
        UserService userService = ctx.getBean(UserService.class);
        boolean flag = userService.login("张三","123");
        if (flag){
            System.out.println("登录成功");
        }else {
            System.out.println("登陆失败");
        }
        UserDao userDao = ctx.getBean(UserDao.class);
        userDao.select();
        userDao.insert();
        userDao.delete();
        userDao.update();
    }
}